package API.RegexAPI.Test;
import java.util.Scanner;

public class IdNumber {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter ID: ");
        String id = sc.nextLine();
        //前六位   [1-9](\\d{5})
        //年份    ((1[8-9]\\d\\d)|(20\\d\\d))
        //月份    (0[1-9]|1[0-2])
        //日期    ((0[1-9])|[1-2]\\d|3[0-1])
        //后四位   ((\\d{3})[\\dxX])
        String Regex1 = "[1-9]\\d{5}(?:18|19|20)\\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\\d|30|31)\\d{3}[\\dXx]";
        String Regex2 = "[1-9](\\d{5})((1[8-9]\\d\\d)|(20\\d\\d))(0[1-9]|1[0-2])((0[1-9])|[1-2]\\d|3[0-1])((\\d{3})[\\dxX])";
        if(id.matches(Regex2)){
            System.out.println("Valid ID");
        } else {
            System.out.println("Invalid ID");
        }
    }
}
